//
//  WFEatListCollectionViewCell.m
//  WeiFang
//
//  Created by WeiFang on 2016/11/21.
//  Copyright © 2020年 WeiFang. All rights reserved.
//

#import "WFEatListCollectionViewCell.h"

@implementation WFEatListCollectionViewCell

- (void)awakeFromNib {
    // Initialization code
    [super awakeFromNib];
}

- (void)setData:(id)data delegate:(id)delegate {

    _delegate = delegate;
    if ([data isKindOfClass:[NSDictionary class]]) {
        if ([data[@"data"] isKindOfClass:[WFEatListCollectionViewCellModel class]]) {
            WFEatListCollectionViewCellModel *model = data[@"data"];
            _model = model;
            _titleLabel.text = model.title;
        }
    }
}

- (IBAction)buttonAction:(UIButton *)sender {
    if (_delegate && [_delegate respondsToSelector:@selector(eatListCollectionViewCell:buttonAction:)]) {
        [_delegate eatListCollectionViewCell:self buttonAction:sender];
    }
}

@end




#pragma mark - Model

@implementation WFEatListCollectionViewCellModel

+ (WFEatListCollectionViewCellModel *)ittemModelWithTitle:(NSString *)title index:(NSInteger)index {
    WFEatListCollectionViewCellModel *model = [WFEatListCollectionViewCellModel new];
    model.title = kSafeString(title);
    model.index = index;
    return model;
}

@end
